package net.easyjava.framework.web.security;

import com.alibaba.fastjson.JSONObject;
import net.easyjava.tools.BaseBean;

/**
 * Created by wxnacy on 16/3/7.
 */
public class UserSecurityBean extends BaseBean {
    private String userId;
    private int status;//用户身份
    private String version;
    private String source;
    private long loginTime;
    private String sign;//加密字段 为userId单独加密后的数据   方式篡改用户id

    public UserSecurityBean() {
    }

    public UserSecurityBean(String userId, int status) {
        this.userId = userId;
        this.status = status;
        this.loginTime = System.currentTimeMillis();
    }

    /**
     *
     * @return
     */
    public String toJsonString(){
        return JSONObject.toJSONString(this);
    }


    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public long getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(long loginTime) {
        this.loginTime = loginTime;
    }

    public static void main(String[] args) {
//        UserSecurityBean userSecurityBean = new UserSecurityBean("test",6);
//        userSecurityBean.setSource("PC");
//        userSecurityBean.setVersion("1.0");
//        String data = userSecurityBean.toJsonString();
//        System.out.println("userSecurityBean.toJsonString() = " + data);
//        AESTools aesTools = new AESTools(AesConstants.KEY_AUDIO_TOKEN);
//        try {
//            System.out.println("aesTools.encrypt() = " + aesTools.encrypt(data));
//        } catch (InvalidKeyException e) {
//            e.printStackTrace();
//        } catch (NoSuchAlgorithmException e) {
//            e.printStackTrace();
//        } catch (InvalidKeySpecException e) {
//            e.printStackTrace();
//        } catch (NoSuchPaddingException e) {
//            e.printStackTrace();
//        } catch (IllegalBlockSizeException e) {
//            e.printStackTrace();
//        } catch (BadPaddingException e) {
//            e.printStackTrace();
//        }

    }
}
